import http from "@/config/config";

const dishApi = {
  //获取菜品
  getDishes:(page: Number,size: Number)=>{
    return http.post(`/dish/page/${page}/${size}`,{}).then(res=>{
        return res.data;
    })
  },
  //聚合搜索，根据名称，状态，分类 分页查询
  pageSearchWrapper:(page: Number,size: Number,map:any)=>{
    return http.post(`/dish/page/${page}/${size}`,{
      "name":map.name,
      "category":map.category,
      "status":map.status
    }).then(res=>{
      return res.data;
  })
},
  
  //添加菜品
  addDish:(dish:any)=>{
    return http.post('/dish/add',{
       "name":dish.name,
       "img":dish.img,
       "price":dish.price,
       "status":dish.status,
       "category":dish.category,
       "description":dish.description,
       "flavourTags":dish.flavourTags
    }).then(res=>{
       return res.data;
    })
  },
  //修改菜品售卖状态
  changeStatus:(id:Number,status:Number)=>{
     return http.get(`/dish/status/${id}/${status}`).then(res=>{
       return res.data;
     })
  },
  //获取菜品的所有的信息，口味，标签
  getDishFlavourTags:(id:Number)=>{
    return http.get(`/dish/info/${id}`).then(res=>{
      return res.data;
    })
  },
   //修改菜品
   updateDish:(dish:any)=>{
    return http.put('/dish/update',{
        "id":dish.id,
       "name":dish.name,
       "img":dish.img,
       "price":dish.price,
       "status":dish.status,
       "category":dish.category,
       "description":dish.description,
       "flavourTags":dish.flavourTags
    }).then(res=>{
       return res.data;
    })
  },
  //批量删除菜品
  deleteDishes:(ids:any)=>{
    return http.post('/dish/delete',{
      "ids":ids
    }).then(res=>{
      return res.data
    })
  },
  //根据分类id全查对应的菜品
  getDishesByCateId:(cateId:Number)=>{
    return http.get(`/dish/getbycateid/${cateId}`).then(res=>{
      return res.data;
    })
  }
//   getUser:(page: Number,size: Number)=>{
//     return http.post(`user/page/${page}/${size}`,
//     {
//       // "username":map.username,
//       // "phone":map.phone,
//       // "name":map.name,
//       // "status":map.status,
//       // "startTime":map.startTime,
//       // "endTime":map.endTime
//     }).then(res=>{
//         return res.data;
//     })
// },

}

export default dishApi;